{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "M_bO5AEJYjtS"
      },
      "source": [
        "\n",
        "\n",
        "\n",
        "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
        "\n",
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]((https://github.com/JohnSnowLabs/nlu/blob/master/examples/colab/Training/sentence_entity_resolution/sentence_entity_resolution_training.ipynb)\n",
        "\n",
        "\n",
        "# Sentence Entity Resolution training\n",
        "Named Entities are sub pieces in textual data which are labled with classes.    \n",
        "These classes and strings are still ambious though and it is not possible to group semantically identically entities withouth any definition of `terminology`.\n",
        "With the `Sentence Resolver` you can train a state of the art deep learning architecture to map entities to their unique terminological representation.\n",
        "\n",
        "A concrete example would be :\n",
        "\n",
        "- The `TSLA` stock is good to buy.\n",
        "- `Tesla, Inc`. is a great company to invest int\n",
        "- The price of `Teslas` stocks is going up\n",
        "\n",
        "`TSLA` , `Tesla`, `Teslas` can be extracted by an NER model an labled as `company` entity class. But we cannot tell programmatically, if all the referring to the same sematic concept, in this case company.     \n",
        "\n",
        "To solve this abigous problem, we can introduce a Terminlogy, where the Tesla company has the ID 21 and every other company in our portfolio get a unique ID aswell.   \n",
        "With a defined terminology at hand and a labled dataset, we can train a chunk resolver to map textually different but semantically equivalent `company entities` to `the same id`.\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "## 1. Colab Setup\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qlZgaz0oXtb6"
      },
      "source": [
        "# Install the johnsnowlabs library\n",
        "! pip install -q johnsnowlabs"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from google.colab import files\n",
        "print('Please Upload your John Snow Labs License using the button below')\n",
        "license_keys = files.upload()"
      ],
      "metadata": {
        "id": "tiyJEsGmN9Hy"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from johnsnowlabs import nlp\n",
        "\n",
        "# After uploading your license run this to install all licensed Python Wheels and pre-download Jars the Spark Session JVM\n",
        "nlp.install()"
      ],
      "metadata": {
        "id": "adVFDvmDOBfG"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "spark=nlp.start()"
      ],
      "metadata": {
        "id": "1AM75UupORAA"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "hp4j0_IluV3y"
      },
      "source": [
        "# Train Sentence Resolver\n",
        "\n",
        "This is a mini example to make you familiar with the dataset structure you must provide for training.\n",
        "Train a chunk resolver on a dataset with columns named `y` , `_y` and `text`. `y` is a label, `_y` is an extra identifier label, `text` is the raw text\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 559
        },
        "id": "cib1vJ_1tJRr",
        "outputId": "e56c920a-fea6-46d2-bd91-9b040fe3aac8"
      },
      "source": [
        "import pandas as pd\n",
        "\n",
        "dataset = pd.DataFrame({\n",
        "    'text': ['The Tesla company is good to invest is', 'TSLA is good to invest','TESLA INC. we should buy','PUT ALL MONEY IN TSLA inc!!'],\n",
        "    'y': ['23','23','23','23'],\n",
        "    '_y': ['TESLA','TESLA','TESLA','TESLA'],\n",
        "\n",
        "})\n",
        "\n",
        "trainable_pipe = nlp.load('train.resolve_sentence')\n",
        "fitted_pipe  = trainable_pipe.fit(dataset)\n",
        "fitted_pipe.predict(dataset.text)"
      ],
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "setInputCols in SentenceEntityResolverApproach_d4f860f61823 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
            "sent_small_bert_L2_128 download started this may take some time.\n",
            "Approximate size to download 16.1 MB\n",
            "[OK!]\n",
            "sentence_detector_dl download started this may take some time.\n",
            "Approximate size to download 354.6 KB\n",
            "[OK!]\n",
            "Warning::Spark Session already created, some configs may not take.\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                                 document  \\\n",
              "0  The Tesla company is good to invest is   \n",
              "1                  TSLA is good to invest   \n",
              "2                TESLA INC. we should buy   \n",
              "3             PUT ALL MONEY IN TSLA inc!!   \n",
              "\n",
              "  resolution_sentence_entity_resolver_code  \\\n",
              "0                                       23   \n",
              "1                                       23   \n",
              "2                                       23   \n",
              "3                                       23   \n",
              "\n",
              "  resolution_sentence_entity_resolver_confidence  \\\n",
              "0                                         1.0000   \n",
              "1                                         1.0000   \n",
              "2                                         1.0000   \n",
              "3                                         1.0000   \n",
              "\n",
              "  resolution_sentence_entity_resolver_distance  \\\n",
              "0                                       0.0000   \n",
              "1                                       0.0000   \n",
              "2                                       0.0000   \n",
              "3                                       0.0000   \n",
              "\n",
              "  resolution_sentence_entity_resolver_origin_sentence  \\\n",
              "0                                                  0    \n",
              "1                                                  0    \n",
              "2                                                  0    \n",
              "3                                                  0    \n",
              "\n",
              "  resolution_sentence_entity_resolver_resolved_text  \\\n",
              "0                                             TESLA   \n",
              "1                                             TESLA   \n",
              "2                                             TESLA   \n",
              "3                                             TESLA   \n",
              "\n",
              "  resolution_sentence_entity_resolver_target_text  \\\n",
              "0          The Tesla company is good to invest is   \n",
              "1                          TSLA is good to invest   \n",
              "2                        TESLA INC. we should buy   \n",
              "3                     PUT ALL MONEY IN TSLA inc!!   \n",
              "\n",
              "  resolution_sentence_entity_resolver_token  \\\n",
              "0    The Tesla company is good to invest is   \n",
              "1                    TSLA is good to invest   \n",
              "2                  TESLA INC. we should buy   \n",
              "3               PUT ALL MONEY IN TSLA inc!!   \n",
              "\n",
              "                sentence_embedding_small_bert_L2_128  \n",
              "0  [[0.5044986009597778, 0.7948187589645386, -0.6...  \n",
              "1  [[-1.1105577945709229, 0.8402332067489624, -1....  \n",
              "2  [[-0.6380321979522705, 0.5634128451347351, -0....  \n",
              "3  [[-1.7485851049423218, 0.26517942547798157, -0...  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-8433b90e-d269-4e57-83f4-eeab9385e4c2\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>document</th>\n",
              "      <th>resolution_sentence_entity_resolver_code</th>\n",
              "      <th>resolution_sentence_entity_resolver_confidence</th>\n",
              "      <th>resolution_sentence_entity_resolver_distance</th>\n",
              "      <th>resolution_sentence_entity_resolver_origin_sentence</th>\n",
              "      <th>resolution_sentence_entity_resolver_resolved_text</th>\n",
              "      <th>resolution_sentence_entity_resolver_target_text</th>\n",
              "      <th>resolution_sentence_entity_resolver_token</th>\n",
              "      <th>sentence_embedding_small_bert_L2_128</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>The Tesla company is good to invest is</td>\n",
              "      <td>23</td>\n",
              "      <td>1.0000</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>TESLA</td>\n",
              "      <td>The Tesla company is good to invest is</td>\n",
              "      <td>The Tesla company is good to invest is</td>\n",
              "      <td>[[0.5044986009597778, 0.7948187589645386, -0.6...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>TSLA is good to invest</td>\n",
              "      <td>23</td>\n",
              "      <td>1.0000</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>TESLA</td>\n",
              "      <td>TSLA is good to invest</td>\n",
              "      <td>TSLA is good to invest</td>\n",
              "      <td>[[-1.1105577945709229, 0.8402332067489624, -1....</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>TESLA INC. we should buy</td>\n",
              "      <td>23</td>\n",
              "      <td>1.0000</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>TESLA</td>\n",
              "      <td>TESLA INC. we should buy</td>\n",
              "      <td>TESLA INC. we should buy</td>\n",
              "      <td>[[-0.6380321979522705, 0.5634128451347351, -0....</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>PUT ALL MONEY IN TSLA inc!!</td>\n",
              "      <td>23</td>\n",
              "      <td>1.0000</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>0</td>\n",
              "      <td>TESLA</td>\n",
              "      <td>PUT ALL MONEY IN TSLA inc!!</td>\n",
              "      <td>PUT ALL MONEY IN TSLA inc!!</td>\n",
              "      <td>[[-1.7485851049423218, 0.26517942547798157, -0...</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-8433b90e-d269-4e57-83f4-eeab9385e4c2')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-8433b90e-d269-4e57-83f4-eeab9385e4c2 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-8433b90e-d269-4e57-83f4-eeab9385e4c2');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-21694028-6b79-468f-b924-7a948ca1014a\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-21694028-6b79-468f-b924-7a948ca1014a')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-21694028-6b79-468f-b924-7a948ca1014a button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 5
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qfoyqShJu5nK"
      },
      "source": [
        "## Train Sentence Resolver with Bert Embeddings\n",
        "By default, GLOVE embeddings will be used. You can you any of the [100+ Word Embeddings]() to train your chunk resolver. If you are handling medical data, biomedical vectors like glove or biobert are a good choice"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "LYqhWOcWbqgD",
        "outputId": "174f56aa-d817-4c36-ac13-b7067646837b"
      },
      "source": [
        "# We can configurevarious parameters on the Chunk resolver\n",
        "trainable_pipe.print_info()\n"
      ],
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",
            ">>> component_list['bert_sentence_embeddings@sent_small_bert_L2_128'] has settable params:\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setBatchSize(8)                          | Info: Size of every batch | Currently set to : 8\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setEngine('tensorflow')                  | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setIsLong(False)                         | Info: Use Long type instead of Int type for inputs buffer - Some Bert models require Long instead of Int. | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setMaxSentenceLength(128)                | Info: Max sentence length to process | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setDimension(128)                        | Info: Number of embedding dimensions | Currently set to : 128\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setCaseSensitive(False)                  | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
            "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n",
            ">>> component_list['document_assembler'] has settable params:\n",
            "component_list['document_assembler'].setCleanupMode('shrink')                                              | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n",
            ">>> component_list['sentence_entity_resolver@sent_small_bert_L2_128'] has settable params:\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setAux_label_col('aux_label')            | Info: Auxiliary label which maps resolved entities to additional labels | Currently set to : aux_label\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setEnableInMemoryStorage(False)          | Info: whether to load whole indexed storage in memory (in-memory lookup) | Currently set to : False\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setIncludeStorage(True)                  | Info: whether to include indexed storage in trained model | Currently set to : True\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setReturnAllKEmbeddings(False)           | Info: Whether to return all embeddings of all K candidates of the resolution. Embeddings will be in the metadata. Increase in RAM usage to be expected | Currently set to : False\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setReturnEuclideanDistances(True)        | Info: Whether to Euclidean distances of the k closest candidates for a chunk/token. | Currently set to : True\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setDistanceFunction('EUCLIDIAN')         | Info: What distance function to use for Word Mover's Distance (WMD). Either 'EUCLIDEAN' or 'COSINE' | Currently set to : EUCLIDIAN\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setMissAsEmpty(True)                     | Info: whether or not to return an empty annotation on unmatched chunks | Currently set to : True\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setNeighbours(25)                        | Info: Number of neighbours to consider in the KNN query to calculate Word Mover's Distance (WMD) | Currently set to : 25\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setReturnCosineDistances(True)           | Info: Extract Cosine Distances. TRUE or False | Currently set to : True\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setThreshold(1000.0)                     | Info: Threshold value for the last distance calculated | Currently set to : 1000.0\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setCaseSensitive(False)                  | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setConfidenceFunction('SOFTMAX')         | Info: what function to use to calculate confidence: Either 'INVERSE' or 'SOFTMAX'. | Currently set to : SOFTMAX\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setDimension(128)                        | Info: Number of embedding dimensions | Currently set to : 128\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n",
            "component_list['sentence_entity_resolver@sent_small_bert_L2_128'].setUseAuxLabel(False)                    | Info: Use AuxLabel Col or not | Currently set to : False\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "XkX-DPI6bO59"
      },
      "source": [
        "# Train a SNOMED resolver\n",
        "We download a sample SNOMED dataset which has we can use for training."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "00QCRKcEbPmq"
      },
      "source": [
        "!wget -q https://raw.githubusercontent.com/JohnSnowLabs/spark-nlp-workshop/master/tutorials/Certification_Trainings/Healthcare/data/AskAPatient.fold-0.test.txt\n",
        "!wget -q https://raw.githubusercontent.com/JohnSnowLabs/spark-nlp-workshop/master/tutorials/Certification_Trainings/Healthcare/data/AskAPatient.fold-0.train.txt"
      ],
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 424
        },
        "id": "Fo30y4S6bRgz",
        "outputId": "f335847d-973d-4081-877b-958d5c91b330"
      },
      "source": [
        "import pandas as pd\n",
        "cols = [\"y\",\"_y\",\"text\"]\n",
        "aap_tr = pd.read_csv(\"AskAPatient.fold-0.train.txt\",sep=\"\\t\",encoding=\"ISO-8859-1\",header=None).iloc[:250]\n",
        "aap_te = pd.read_csv(\"AskAPatient.fold-0.test.txt\",sep=\"\\t\",encoding=\"ISO-8859-1\",header=None).iloc[:250]\n",
        "aap_tr.columns = cols\n",
        "aap_te.columns = cols\n",
        "aap_tr\n"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                    y                       _y                     text\n",
              "0           108367008     Dislocation of joint     Dislocation of joint\n",
              "1    3384011000036100                Arthrotec                Arthrotec\n",
              "2           166717003  Serum creatinine raised  Serum creatinine raised\n",
              "3    3877011000036101                  Lipitor                  Lipitor\n",
              "4           402234004              Foot eczema              Foot eczema\n",
              "..                ...                      ...                      ...\n",
              "245         162290004                 Dry eyes                 Dry eyes\n",
              "246         419723007            Mentally dull            Mentally dull\n",
              "247  4216011000036104                  Norvasc                  Norvasc\n",
              "248          13791008                 Asthenia                 Asthenia\n",
              "249         162059005            Upset stomach            Upset stomach\n",
              "\n",
              "[250 rows x 3 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-f4025242-6aa2-4c5f-a21f-11bd5f71444f\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>y</th>\n",
              "      <th>_y</th>\n",
              "      <th>text</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>108367008</td>\n",
              "      <td>Dislocation of joint</td>\n",
              "      <td>Dislocation of joint</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>3384011000036100</td>\n",
              "      <td>Arthrotec</td>\n",
              "      <td>Arthrotec</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>166717003</td>\n",
              "      <td>Serum creatinine raised</td>\n",
              "      <td>Serum creatinine raised</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>3877011000036101</td>\n",
              "      <td>Lipitor</td>\n",
              "      <td>Lipitor</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>402234004</td>\n",
              "      <td>Foot eczema</td>\n",
              "      <td>Foot eczema</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>245</th>\n",
              "      <td>162290004</td>\n",
              "      <td>Dry eyes</td>\n",
              "      <td>Dry eyes</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>246</th>\n",
              "      <td>419723007</td>\n",
              "      <td>Mentally dull</td>\n",
              "      <td>Mentally dull</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>247</th>\n",
              "      <td>4216011000036104</td>\n",
              "      <td>Norvasc</td>\n",
              "      <td>Norvasc</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>248</th>\n",
              "      <td>13791008</td>\n",
              "      <td>Asthenia</td>\n",
              "      <td>Asthenia</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>249</th>\n",
              "      <td>162059005</td>\n",
              "      <td>Upset stomach</td>\n",
              "      <td>Upset stomach</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>250 rows × 3 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-f4025242-6aa2-4c5f-a21f-11bd5f71444f')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-f4025242-6aa2-4c5f-a21f-11bd5f71444f button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-f4025242-6aa2-4c5f-a21f-11bd5f71444f');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-47feaabb-1d61-4bb4-b642-f4a2535e229c\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-47feaabb-1d61-4bb4-b642-f4a2535e229c')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-47feaabb-1d61-4bb4-b642-f4a2535e229c button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "5ngBy_2CbwIY",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 808
        },
        "outputId": "50f25786-0dc4-448e-c5f5-d1cd417acd6b"
      },
      "source": [
        "# Healthcare Embeddings\n",
        "trainable_pipe = nlp.load('en.embed_sentence.bert.jsl_tiny_umls_uncased train.resolve_sentence')\n",
        "trainable_pipe['trainable_sentence_entity_resolver'].setNeighbours(4)\n",
        "fitted_pipe  = trainable_pipe.fit(aap_tr)\n",
        "prediction = fitted_pipe.predict(aap_tr)\n",
        "prediction"
      ],
      "execution_count": 12,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Warning::Spark Session already created, some configs may not take.\n",
            "Warning::Spark Session already created, some configs may not take.\n",
            "sbert_jsl_tiny_umls_uncased download started this may take some time.\n",
            "Approximate size to download 15.8 MB\n",
            "[OK!]\n",
            "setInputCols in SentenceEntityResolverApproach_2520cda31704 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
            "sentence_detector_dl download started this may take some time.\n",
            "Approximate size to download 354.6 KB\n",
            "[OK!]\n",
            "Warning::Spark Session already created, some configs may not take.\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "                          _y                 document  \\\n",
              "0       Dislocation of joint     Dislocation of joint   \n",
              "1                  Arthrotec                Arthrotec   \n",
              "2    Serum creatinine raised  Serum creatinine raised   \n",
              "3                    Lipitor                  Lipitor   \n",
              "4                Foot eczema              Foot eczema   \n",
              "..                       ...                      ...   \n",
              "245                 Dry eyes                 Dry eyes   \n",
              "246            Mentally dull            Mentally dull   \n",
              "247                  Norvasc                  Norvasc   \n",
              "248                 Asthenia                 Asthenia   \n",
              "249            Upset stomach            Upset stomach   \n",
              "\n",
              "    resolution_sentence_entity_resolver_code  \\\n",
              "0                                  108367008   \n",
              "1                           3384011000036100   \n",
              "2                                  166717003   \n",
              "3                           3877011000036101   \n",
              "4                                  402234004   \n",
              "..                                       ...   \n",
              "245                                162290004   \n",
              "246                                419723007   \n",
              "247                         4216011000036104   \n",
              "248                                 13791008   \n",
              "249                                162059005   \n",
              "\n",
              "    resolution_sentence_entity_resolver_confidence  \\\n",
              "0                                           0.9992   \n",
              "1                                           0.9921   \n",
              "2                                           0.9975   \n",
              "3                                           1.0000   \n",
              "4                                           0.9942   \n",
              "..                                             ...   \n",
              "245                                         0.9981   \n",
              "246                                         1.0000   \n",
              "247                                         0.9864   \n",
              "248                                         1.0000   \n",
              "249                                         0.9960   \n",
              "\n",
              "    resolution_sentence_entity_resolver_distance  \\\n",
              "0                                         0.0000   \n",
              "1                                         0.0000   \n",
              "2                                         0.0000   \n",
              "3                                         0.0000   \n",
              "4                                         0.0000   \n",
              "..                                           ...   \n",
              "245                                       0.0000   \n",
              "246                                       0.0000   \n",
              "247                                       0.0000   \n",
              "248                                       0.0000   \n",
              "249                                       0.0000   \n",
              "\n",
              "           resolution_sentence_entity_resolver_k_codes  \\\n",
              "0          [[108367008, 21288011000036105, 404640003]]   \n",
              "1                       [[3384011000036100, 57676002]]   \n",
              "2         [[166717003, 39575007, 13644009, 124055002]]   \n",
              "3                                                  NaN   \n",
              "4    [[402234004, 21930011000036101, 41710110000361...   \n",
              "..                                                 ...   \n",
              "245                [[162290004, 238810007, 404640003]]   \n",
              "246                                                NaN   \n",
              "247  [[4216011000036104, 2929011000036108, 367391008]]   \n",
              "248                                                NaN   \n",
              "249                 [[162059005, 271681002, 25064002]]   \n",
              "\n",
              "    resolution_sentence_entity_resolver_k_confidences  \\\n",
              "0                          [[0.9992, 0.0005, 0.0004]]   \n",
              "1                                  [[0.9921, 0.0079]]   \n",
              "2                  [[0.9975, 0.0011, 0.0009, 0.0005]]   \n",
              "3                                                 NaN   \n",
              "4                  [[0.9942, 0.0025, 0.0020, 0.0013]]   \n",
              "..                                                ...   \n",
              "245                        [[0.9981, 0.0013, 0.0006]]   \n",
              "246                                               NaN   \n",
              "247                        [[0.9864, 0.0080, 0.0056]]   \n",
              "248                                               NaN   \n",
              "249                        [[0.9960, 0.0030, 0.0010]]   \n",
              "\n",
              "    resolution_sentence_entity_resolver_k_cos_distances  \\\n",
              "0                           [[0.0000, 0.2300, 0.2344]]    \n",
              "1                                   [[0.0000, 0.0922]]    \n",
              "2                   [[0.0000, 0.1798, 0.2049, 0.2325]]    \n",
              "3                                                  NaN    \n",
              "4                   [[0.0000, 0.1463, 0.1500, 0.1788]]    \n",
              "..                                                 ...    \n",
              "245                         [[0.0000, 0.1612, 0.2016]]    \n",
              "246                                                NaN    \n",
              "247                         [[0.0000, 0.0863, 0.1000]]    \n",
              "248                                                NaN    \n",
              "249                         [[0.0000, 0.1238, 0.1752]]    \n",
              "\n",
              "    resolution_sentence_entity_resolver_k_distances  \\\n",
              "0                        [[0.0000, 7.7017, 7.9164]]   \n",
              "1                                [[0.0000, 4.8368]]   \n",
              "2                [[0.0000, 6.7997, 7.0506, 7.5232]]   \n",
              "3                                               NaN   \n",
              "4                [[0.0000, 6.0054, 6.1894, 6.6619]]   \n",
              "..                                              ...   \n",
              "245                      [[0.0000, 6.6192, 7.4328]]   \n",
              "246                                             NaN   \n",
              "247                      [[0.0000, 4.8183, 5.1746]]   \n",
              "248                                             NaN   \n",
              "249                      [[0.0000, 5.8050, 6.9000]]   \n",
              "\n",
              "      resolution_sentence_entity_resolver_k_resolution  \\\n",
              "0      [[Dislocation of joint, diclofenac, Dizziness]]   \n",
              "1                            [[Arthrotec, Arthralgia]]   \n",
              "2    [[Serum creatinine raised, Urine looks dark, H...   \n",
              "3                                                  NaN   \n",
              "4     [[Foot eczema, ezetimibe, Celebrex, Arthralgia]]   \n",
              "..                                                 ...   \n",
              "245                  [[Dry eyes, Flushing, Dizziness]]   \n",
              "246                                                NaN   \n",
              "247                       [[Norvasc, Nexium, Malaise]]   \n",
              "248                                                NaN   \n",
              "249          [[Upset stomach, Stomach ache, Headache]]   \n",
              "\n",
              "    resolution_sentence_entity_resolver_origin_sentence  \\\n",
              "0                                                    0    \n",
              "1                                                    0    \n",
              "2                                                    0    \n",
              "3                                                    0    \n",
              "4                                                    0    \n",
              "..                                                 ...    \n",
              "245                                                  0    \n",
              "246                                                  0    \n",
              "247                                                  0    \n",
              "248                                                  0    \n",
              "249                                                  0    \n",
              "\n",
              "    resolution_sentence_entity_resolver_resolved_text  \\\n",
              "0                                Dislocation of joint   \n",
              "1                                           Arthrotec   \n",
              "2                             Serum creatinine raised   \n",
              "3                                             Lipitor   \n",
              "4                                         Foot eczema   \n",
              "..                                                ...   \n",
              "245                                          Dry eyes   \n",
              "246                                     Mentally dull   \n",
              "247                                           Norvasc   \n",
              "248                                          Asthenia   \n",
              "249                                     Upset stomach   \n",
              "\n",
              "    resolution_sentence_entity_resolver_target_text  \\\n",
              "0                              Dislocation of joint   \n",
              "1                                         Arthrotec   \n",
              "2                           Serum creatinine raised   \n",
              "3                                           Lipitor   \n",
              "4                                       Foot eczema   \n",
              "..                                              ...   \n",
              "245                                        Dry eyes   \n",
              "246                                   Mentally dull   \n",
              "247                                         Norvasc   \n",
              "248                                        Asthenia   \n",
              "249                                   Upset stomach   \n",
              "\n",
              "    resolution_sentence_entity_resolver_token  \\\n",
              "0                        Dislocation of joint   \n",
              "1                                   Arthrotec   \n",
              "2                     Serum creatinine raised   \n",
              "3                                     Lipitor   \n",
              "4                                 Foot eczema   \n",
              "..                                        ...   \n",
              "245                                  Dry eyes   \n",
              "246                             Mentally dull   \n",
              "247                                   Norvasc   \n",
              "248                                  Asthenia   \n",
              "249                             Upset stomach   \n",
              "\n",
              "                               sentence_embedding_bert  \\\n",
              "0    [[-0.9687817692756653, -0.31864216923713684, -...   \n",
              "1    [[-0.7108752131462097, -0.5266207456588745, -0...   \n",
              "2    [[-0.5410001277923584, -2.0953280925750732, 0....   \n",
              "3    [[-0.45240962505340576, -1.394622564315796, -0...   \n",
              "4    [[-0.763110876083374, -0.40250054001808167, -0...   \n",
              "..                                                 ...   \n",
              "245  [[-0.03702589124441147, -1.3459508419036865, -...   \n",
              "246  [[-0.9327226281166077, -1.3695887327194214, -0...   \n",
              "247  [[-0.4530910551548004, -1.576862096786499, -0....   \n",
              "248  [[-0.5592130422592163, -1.6610543727874756, -0...   \n",
              "249  [[-2.242663860321045, -0.9422457814216614, 0.0...   \n",
              "\n",
              "                        text                 y  \n",
              "0       Dislocation of joint         108367008  \n",
              "1                  Arthrotec  3384011000036100  \n",
              "2    Serum creatinine raised         166717003  \n",
              "3                    Lipitor  3877011000036101  \n",
              "4                Foot eczema         402234004  \n",
              "..                       ...               ...  \n",
              "245                 Dry eyes         162290004  \n",
              "246            Mentally dull         419723007  \n",
              "247                  Norvasc  4216011000036104  \n",
              "248                 Asthenia          13791008  \n",
              "249            Upset stomach         162059005  \n",
              "\n",
              "[250 rows x 17 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-318c2b28-b61f-41f0-a28a-8085bc230798\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>_y</th>\n",
              "      <th>document</th>\n",
              "      <th>resolution_sentence_entity_resolver_code</th>\n",
              "      <th>resolution_sentence_entity_resolver_confidence</th>\n",
              "      <th>resolution_sentence_entity_resolver_distance</th>\n",
              "      <th>resolution_sentence_entity_resolver_k_codes</th>\n",
              "      <th>resolution_sentence_entity_resolver_k_confidences</th>\n",
              "      <th>resolution_sentence_entity_resolver_k_cos_distances</th>\n",
              "      <th>resolution_sentence_entity_resolver_k_distances</th>\n",
              "      <th>resolution_sentence_entity_resolver_k_resolution</th>\n",
              "      <th>resolution_sentence_entity_resolver_origin_sentence</th>\n",
              "      <th>resolution_sentence_entity_resolver_resolved_text</th>\n",
              "      <th>resolution_sentence_entity_resolver_target_text</th>\n",
              "      <th>resolution_sentence_entity_resolver_token</th>\n",
              "      <th>sentence_embedding_bert</th>\n",
              "      <th>text</th>\n",
              "      <th>y</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Dislocation of joint</td>\n",
              "      <td>Dislocation of joint</td>\n",
              "      <td>108367008</td>\n",
              "      <td>0.9992</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>[[108367008, 21288011000036105, 404640003]]</td>\n",
              "      <td>[[0.9992, 0.0005, 0.0004]]</td>\n",
              "      <td>[[0.0000, 0.2300, 0.2344]]</td>\n",
              "      <td>[[0.0000, 7.7017, 7.9164]]</td>\n",
              "      <td>[[Dislocation of joint, diclofenac, Dizziness]]</td>\n",
              "      <td>0</td>\n",
              "      <td>Dislocation of joint</td>\n",
              "      <td>Dislocation of joint</td>\n",
              "      <td>Dislocation of joint</td>\n",
              "      <td>[[-0.9687817692756653, -0.31864216923713684, -...</td>\n",
              "      <td>Dislocation of joint</td>\n",
              "      <td>108367008</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>Arthrotec</td>\n",
              "      <td>Arthrotec</td>\n",
              "      <td>3384011000036100</td>\n",
              "      <td>0.9921</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>[[3384011000036100, 57676002]]</td>\n",
              "      <td>[[0.9921, 0.0079]]</td>\n",
              "      <td>[[0.0000, 0.0922]]</td>\n",
              "      <td>[[0.0000, 4.8368]]</td>\n",
              "      <td>[[Arthrotec, Arthralgia]]</td>\n",
              "      <td>0</td>\n",
              "      <td>Arthrotec</td>\n",
              "      <td>Arthrotec</td>\n",
              "      <td>Arthrotec</td>\n",
              "      <td>[[-0.7108752131462097, -0.5266207456588745, -0...</td>\n",
              "      <td>Arthrotec</td>\n",
              "      <td>3384011000036100</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>Serum creatinine raised</td>\n",
              "      <td>Serum creatinine raised</td>\n",
              "      <td>166717003</td>\n",
              "      <td>0.9975</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>[[166717003, 39575007, 13644009, 124055002]]</td>\n",
              "      <td>[[0.9975, 0.0011, 0.0009, 0.0005]]</td>\n",
              "      <td>[[0.0000, 0.1798, 0.2049, 0.2325]]</td>\n",
              "      <td>[[0.0000, 6.7997, 7.0506, 7.5232]]</td>\n",
              "      <td>[[Serum creatinine raised, Urine looks dark, H...</td>\n",
              "      <td>0</td>\n",
              "      <td>Serum creatinine raised</td>\n",
              "      <td>Serum creatinine raised</td>\n",
              "      <td>Serum creatinine raised</td>\n",
              "      <td>[[-0.5410001277923584, -2.0953280925750732, 0....</td>\n",
              "      <td>Serum creatinine raised</td>\n",
              "      <td>166717003</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>Lipitor</td>\n",
              "      <td>Lipitor</td>\n",
              "      <td>3877011000036101</td>\n",
              "      <td>1.0000</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>Lipitor</td>\n",
              "      <td>Lipitor</td>\n",
              "      <td>Lipitor</td>\n",
              "      <td>[[-0.45240962505340576, -1.394622564315796, -0...</td>\n",
              "      <td>Lipitor</td>\n",
              "      <td>3877011000036101</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>Foot eczema</td>\n",
              "      <td>Foot eczema</td>\n",
              "      <td>402234004</td>\n",
              "      <td>0.9942</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>[[402234004, 21930011000036101, 41710110000361...</td>\n",
              "      <td>[[0.9942, 0.0025, 0.0020, 0.0013]]</td>\n",
              "      <td>[[0.0000, 0.1463, 0.1500, 0.1788]]</td>\n",
              "      <td>[[0.0000, 6.0054, 6.1894, 6.6619]]</td>\n",
              "      <td>[[Foot eczema, ezetimibe, Celebrex, Arthralgia]]</td>\n",
              "      <td>0</td>\n",
              "      <td>Foot eczema</td>\n",
              "      <td>Foot eczema</td>\n",
              "      <td>Foot eczema</td>\n",
              "      <td>[[-0.763110876083374, -0.40250054001808167, -0...</td>\n",
              "      <td>Foot eczema</td>\n",
              "      <td>402234004</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>245</th>\n",
              "      <td>Dry eyes</td>\n",
              "      <td>Dry eyes</td>\n",
              "      <td>162290004</td>\n",
              "      <td>0.9981</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>[[162290004, 238810007, 404640003]]</td>\n",
              "      <td>[[0.9981, 0.0013, 0.0006]]</td>\n",
              "      <td>[[0.0000, 0.1612, 0.2016]]</td>\n",
              "      <td>[[0.0000, 6.6192, 7.4328]]</td>\n",
              "      <td>[[Dry eyes, Flushing, Dizziness]]</td>\n",
              "      <td>0</td>\n",
              "      <td>Dry eyes</td>\n",
              "      <td>Dry eyes</td>\n",
              "      <td>Dry eyes</td>\n",
              "      <td>[[-0.03702589124441147, -1.3459508419036865, -...</td>\n",
              "      <td>Dry eyes</td>\n",
              "      <td>162290004</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>246</th>\n",
              "      <td>Mentally dull</td>\n",
              "      <td>Mentally dull</td>\n",
              "      <td>419723007</td>\n",
              "      <td>1.0000</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>Mentally dull</td>\n",
              "      <td>Mentally dull</td>\n",
              "      <td>Mentally dull</td>\n",
              "      <td>[[-0.9327226281166077, -1.3695887327194214, -0...</td>\n",
              "      <td>Mentally dull</td>\n",
              "      <td>419723007</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>247</th>\n",
              "      <td>Norvasc</td>\n",
              "      <td>Norvasc</td>\n",
              "      <td>4216011000036104</td>\n",
              "      <td>0.9864</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>[[4216011000036104, 2929011000036108, 367391008]]</td>\n",
              "      <td>[[0.9864, 0.0080, 0.0056]]</td>\n",
              "      <td>[[0.0000, 0.0863, 0.1000]]</td>\n",
              "      <td>[[0.0000, 4.8183, 5.1746]]</td>\n",
              "      <td>[[Norvasc, Nexium, Malaise]]</td>\n",
              "      <td>0</td>\n",
              "      <td>Norvasc</td>\n",
              "      <td>Norvasc</td>\n",
              "      <td>Norvasc</td>\n",
              "      <td>[[-0.4530910551548004, -1.576862096786499, -0....</td>\n",
              "      <td>Norvasc</td>\n",
              "      <td>4216011000036104</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>248</th>\n",
              "      <td>Asthenia</td>\n",
              "      <td>Asthenia</td>\n",
              "      <td>13791008</td>\n",
              "      <td>1.0000</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>0</td>\n",
              "      <td>Asthenia</td>\n",
              "      <td>Asthenia</td>\n",
              "      <td>Asthenia</td>\n",
              "      <td>[[-0.5592130422592163, -1.6610543727874756, -0...</td>\n",
              "      <td>Asthenia</td>\n",
              "      <td>13791008</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>249</th>\n",
              "      <td>Upset stomach</td>\n",
              "      <td>Upset stomach</td>\n",
              "      <td>162059005</td>\n",
              "      <td>0.9960</td>\n",
              "      <td>0.0000</td>\n",
              "      <td>[[162059005, 271681002, 25064002]]</td>\n",
              "      <td>[[0.9960, 0.0030, 0.0010]]</td>\n",
              "      <td>[[0.0000, 0.1238, 0.1752]]</td>\n",
              "      <td>[[0.0000, 5.8050, 6.9000]]</td>\n",
              "      <td>[[Upset stomach, Stomach ache, Headache]]</td>\n",
              "      <td>0</td>\n",
              "      <td>Upset stomach</td>\n",
              "      <td>Upset stomach</td>\n",
              "      <td>Upset stomach</td>\n",
              "      <td>[[-2.242663860321045, -0.9422457814216614, 0.0...</td>\n",
              "      <td>Upset stomach</td>\n",
              "      <td>162059005</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>250 rows × 17 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-318c2b28-b61f-41f0-a28a-8085bc230798')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-318c2b28-b61f-41f0-a28a-8085bc230798 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-318c2b28-b61f-41f0-a28a-8085bc230798');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-af285d59-2915-4dac-a424-790292858db5\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-af285d59-2915-4dac-a424-790292858db5')\"\n",
              "            title=\"Suggest charts.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-af285d59-2915-4dac-a424-790292858db5 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ]
          },
          "metadata": {},
          "execution_count": 12
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "Yg52noo6PIYV"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}